import request from '@/config/axios'

export interface ChannelVO {
  id: number
  name: string
  domain: string
  points: number
  status: number
  economizePrice: number
  preferentialRatio: number
  createTime: Date
  url: string
}

export interface UpdateStatusReqVO {
  id: number
  status: number
}

// 创建商城链接配置
export const createChannelLink = async (data) => {
  return await request.post({
    url: '/promotion/channel-link/create',
    data: data
  })
}

// 更新商城链接配置
export const updateChannelLink = async (data) => {
  return await request.put({
    url: '/promotion/channel-link/update',
    data: data
  })
}

// 删除商城链接配置
export const deleteChannelLink = async (id) => {
  return request.get({
    url: '/promotion/channel-link/delete?id=' + id,
    method: 'delete'
  })
}

// 获得商城链接配置
export const getChannelLink = async (id) => {
  return request.get({
    url: '/promotion/channel-link/get?id=' + id,
    method: 'get'
  })
}

// 获得商城链接配置分页
export const getChannelLinkPage = async (query) => {
  return request.get({
    url: '/promotion/channel-link/page',
    method: 'get',
    params: query
  })
}

// 导出商城链接配置 Excel
export const exportChannelLinkExcel = async (query) => {
  return request.get({
    url: '/promotion/channel-link/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 关闭积分活动
export const closeChannelLink = async (id: number) => {
  return await request.put({ url: '/promotion/channel-link/close?id=' + id })
}
